<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Axios Demo案例</title>
    <script src="js/axios.min.js"></script>
</head>
<body>


<button onclick="onClickAxios()">发送Axios请求</button>
<br>

<button onclick="onClickAxios2()">发送Axios POST请求</button>

</body>
<script type="text/javascript">

    function onClickAxios() {
        //1.创建对象
        axios({
            url: '/Axios-01/axiosServlet',
            method: 'GET'
        })
            .then(function (response) {
                alert(response.data.userName)
            })

    }

    function onClickAxios2() {

        axios({
            url: '/Axios-01/axiosServlet2',
            method: 'POST',
            data: {'userName': 'admin'}
        }).then((response) => {

            console.log(response.data)

        })

        //vue 箭头函数
    }

</script>
</html>